package com.hshoesmall.demo.controller;

import com.hshoesmall.demo.common.api.ApiResult;
import com.hshoesmall.demo.model.dto.ShoesOrderShoesDTO;
import com.hshoesmall.demo.model.entity.ShoesOrderShoes;
import com.hshoesmall.demo.service.ShoesOrderShoesService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/ordersShoes")
public class ShoesorderShoesController {

    @Resource
    ShoesOrderShoesService shoesOrderShoesService;

    @PostMapping("/addOrderShoes")
    public ApiResult<Map<String, Object>> addOrder2(@RequestBody ShoesOrderShoesDTO dto) {
        ShoesOrderShoes order1 = shoesOrderShoesService.addOrderShoes(dto);

        if (ObjectUtils.isEmpty(order1)) {
            return ApiResult.failed("订单提交失败");
        }
        Map<String, Object> map = new HashMap<>(16);
        map.put("order1", order1);
        return ApiResult.success(map);
    }
}
